﻿
using System;
namespace RakutenCrawler.Repository
{
    public class SubGenreRepository : GenericRepository<SubGenre>
    {
        public SubGenreRepository():base()
        {

        }

        public SubGenreRepository(bool lazyload):base(lazyload)
        {

        }
        public override void InsertOrUpdate(SubGenre item)
        {
            var check = Single(s => s.SubGenreURL == item.SubGenreURL || item.SubGenreId == s.SubGenreId);
            if (check == null)
            {
                item.InsertedDate = DateTime.Now;
                All.AddObject(item);
            }
            else
            {
                item.InsertedDate = check.InsertedDate;
                item.SubGenreId = check.SubGenreId;
                All.ApplyCurrentValues(item);
            }

        }
    }
}
